package com.hanthink.web.controller.pc;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hanthink.common.annotation.Log;
import com.hanthink.common.core.controller.BaseController;
import com.hanthink.common.core.domain.AjaxResult;
import com.hanthink.common.enums.BusinessType;
import com.hanthink.common.utils.poi.ExcelUtil;
import com.hanthink.system.domain.pc.EmResourceCallFault;
import com.hanthink.system.service.pc.IEmResourceCallFaultService;
import com.hanthink.common.core.page.TableDataInfo;

/**
 * 问题描述Controller
 * 
 * @author hanthink
 * @date 2021-01-25
 */
@RestController
@RequestMapping("/equipment/callFault")
public class EmResourceCallFaultController extends BaseController
{
    @Autowired
    private IEmResourceCallFaultService emResourceCallFaultService;

    /**
     * 查询问题描述列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:callFault:list')")
    @GetMapping("/list")
    public TableDataInfo list(EmResourceCallFault emResourceCallFault)
    {
        startPage();
        List<EmResourceCallFault> list = emResourceCallFaultService.selectEmResourceCallFaultList(emResourceCallFault);
        return getDataTable(list);
    }

    /**
     * 导出问题描述列表
     */
    @Log(title = "问题描述", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(EmResourceCallFault emResourceCallFault)
    {
        List<EmResourceCallFault> list = emResourceCallFaultService.selectEmResourceCallFaultList(emResourceCallFault);
        ExcelUtil<EmResourceCallFault> util = new ExcelUtil<EmResourceCallFault>(EmResourceCallFault.class);
        return util.exportExcel(list, "callFault");
    }

    /**
     * 获取问题描述详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(emResourceCallFaultService.selectEmResourceCallFaultById(id));
    }

    /**
     * 新增问题描述
     */
    @PreAuthorize("@ss.hasPermi('equipment:callFault:add')")
    @Log(title = "问题描述", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EmResourceCallFault emResourceCallFault)
    {
        return toAjax(emResourceCallFaultService.insertEmResourceCallFault(emResourceCallFault));
    }

    /**
     * 修改问题描述
     */
    @PreAuthorize("@ss.hasPermi('equipment:callFault:edit')")
    @Log(title = "问题描述", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EmResourceCallFault emResourceCallFault)
    {
        return toAjax(emResourceCallFaultService.updateEmResourceCallFault(emResourceCallFault));
    }

    /**
     * 删除问题描述
     */
    @PreAuthorize("@ss.hasPermi('equipment:callFault:remove')")
    @Log(title = "问题描述", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emResourceCallFaultService.deleteEmResourceCallFaultByIds(ids));
    }
}
